package com.itqf.controller;

import com.itqf.pojo.Role;
import com.itqf.service.RoleService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * projectName: rbacgp8
 *
 * @author: 赵伟风
 * time: 2021/8/12 11:08
 * description:
 */
@RequestMapping("permission")
@Controller
public class PermissonController {

    @Autowired
    private RoleService roleService;

    @RequiresPermissions("权限分配")
    @GetMapping("grant")
    public String plan(HttpServletRequest request){

        //查询所有角色
        List<Role> roles =  roleService.findAll();

        request.setAttribute("roles", roles);

        return "permission/grant";
    }


    @GetMapping("change")
    public String change(String [] roles){

        //1.用户角色的中间表,根据用户uid删除所有数据

        //2.roleid和用户id 中间表插入数据

        //3.修改完到哪个页面
        //退出登录
        return "permission/grant";
    }


}
